/**
 * @Author: 健聪
 * @Description: 计算属性
 * @Date: 2024/1/13
 */
void main() {
  var rect = new Rectangle();
  rect.height = 20;
  rect.width = 10;

  // print(rect.area());
  print(rect.area);

  rect.area = 200;
  print(rect.width);
}

class Rectangle {
  num width=0, height=0;

  // num area(){
  //   return width * height;
  // }
  // 计算属性写法1
  // num get area{
  //   return width * height;
  // }
  // 计算属性写法2
  num get area => width * height;
      // set area(value){
      //   width = value / 20;
      // }
      set area(value) => value / 20;
}